Skip to content

test Trailer Iterable overloads with non-List Iterables - #1383

Merged
pjfanning merged 1 commit into
apache:mainfrom
pjfanning:trailer-iterable-shape-tests
Nov 3, 2026
Merged

pjfanning merged 1 commit into
apache:mainfrom
pjfanning:trailer-iterable-shape-tests

Conversation

@pjfanning

Copy link
Copy Markdown
Member

Motivation

#1374 added java.lang.Iterable overloads to Trailer.addHeaders / withHeaders, but its tests only passed Lists. The overloads should accept any java.lang.Iterable.

Modification

Test-only change to TrailerTest:

  • addHeaders / withHeaders with the same headers as an ArrayList, LinkedHashSet, ArrayDeque, unmodifiable Collection and a non-Collection Iterable (items::iterator)
  • a one-shot Iterable that fails on a second traversal, so the conversion must iterate only once
  • withHeaders of an empty Iterable removes all headers

Result

The Trailer Java API overloads are tested with several Iterable shapes, not just List.

Tests

  • sbt "http-core/Test/testOnly org.apache.pekko.http.javadsl.model.TrailerTest": passed (7 tests)
  • sbt http-core/Test/javafmtCheck (JDK 17): passed

References

Refs #1374, Refs #1378

Motivation:
The java.lang.Iterable overloads of Trailer.addHeaders and withHeaders
(apache#1374) should accept any java.lang.Iterable, not just Lists.

Modification:
Run addHeaders/withHeaders with the same headers as an ArrayList,
LinkedHashSet, ArrayDeque, unmodifiable Collection and a non-Collection
Iterable. Add tests that the Iterable is traversed once and that
withHeaders of an empty Iterable clears the headers.

Result:
The Trailer Java API overloads are tested with several Iterable shapes.

Tests:
- sbt "http-core/Test/testOnly org.apache.pekko.http.javadsl.model.TrailerTest" - passed

References:
Refs apache#1374, Refs apache#1378

@He-Pin He-Pin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pjfanning
pjfanning merged commit c091756 into apache:main Nov 3, 2026
6 checks passed
@pjfanning
pjfanning deleted the trailer-iterable-shape-tests branch November 3, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants